USE [HelpUs]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_usuOrganizacaoendereco]') AND parent_object_id = OBJECT_ID(N'[dbo].[enderecoSets]'))
ALTER TABLE [dbo].[enderecoSets] DROP CONSTRAINT [FK_usuOrganizacaoendereco]
GO

USE [HelpUs]
GO

/****** Object:  Table [dbo].[enderecoSets]    Script Date: 05/21/2012 22:38:37 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[enderecoSets]') AND type in (N'U'))
DROP TABLE [dbo].[enderecoSets]
GO

USE [HelpUs]
GO

/****** Object:  Table [dbo].[enderecoSets]    Script Date: 05/21/2012 22:38:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[enderecoSets](
	[idEndereco] [int] IDENTITY(1,1) NOT NULL,
	[rua] [nvarchar](50) NOT NULL,
	[bairro] [nvarchar](50) NOT NULL,
	[numero] [nvarchar](50) NOT NULL,
	[cidade] [nvarchar](50) NOT NULL,
	[cep] [nvarchar](12) NOT NULL,
	[estado] [nvarchar](2) NOT NULL,
	[idUsuOrganizacao_idOrg] [int] NOT NULL,
 CONSTRAINT [PK_enderecoSets] PRIMARY KEY CLUSTERED 
(
	[idEndereco] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[enderecoSets]  WITH CHECK ADD  CONSTRAINT [FK_usuOrganizacaoendereco] FOREIGN KEY([idUsuOrganizacao_idOrg])
REFERENCES [dbo].[enderecoSet_usuOrganizacao] ([idOrg])
GO

ALTER TABLE [dbo].[enderecoSets] CHECK CONSTRAINT [FK_usuOrganizacaoendereco]
GO


